package report;

import java.io.File;
import java.io.FileOutputStream;

import javax.servlet.http.HttpServletRequest;

import jxl.Workbook;
import jxl.write.WritableWorkbook;

public class ReportService {
	public void buildReport(String group,String company,String chinnel,String town,String kehu,String ad,String channelres,String community,String business,String employee,String net,String groupjr,String netbusiness,String wuye,String office,String cheliang,String chanpin,String kpi,String mkehu,String shouru,String chengben,String groupproduct,String year,String month,HttpServletRequest request,java.io.OutputStream out){
		try{
//			File file=new File("d:/report.xls");
//			FileOutputStream out=new FileOutputStream(file);
			WritableWorkbook wwb = Workbook.createWorkbook(out);
			if(null!=group ){
				GroupReportService groupReportSer=new GroupReportService();
				groupReportSer.buildReport(wwb,year,month);
			}
			if(null!=company ){
				CompayReportService companyReportSer=new CompayReportService();
				companyReportSer.buildReport(wwb,year,month);
			}
			if(null!=chinnel ){
				ChannelReportService chinnelReportSer=new ChannelReportService();
				chinnelReportSer.buildReport(wwb,year,month);
			}
			if(null!=town){
				TownReportService townReport=new TownReportService();
				townReport.buildReport(wwb, year, month);
			}
			if(null!=kehu){
				CustomerReportService kehuReport=new CustomerReportService();
				kehuReport.buildReport(wwb, year, month,request);
			}
			if(null!=ad){
				AdresReportService adReport=new AdresReportService();
				adReport.buildReport(wwb, year, month,request);
			}
			if(null!=channelres){
				ChannelresReportService qudaoReport=new ChannelresReportService();
				qudaoReport.buildReport(wwb, year, month,request);
			}
			if(null!=community){
				CommunityresReportService shequReport=new CommunityresReportService();
				shequReport.buildReport(wwb, year, month,request);
			}
			if(null!=business){
				BusinessresReportService yewuReport=new BusinessresReportService();
				yewuReport.buildReport(wwb, year, month);
			}
			
			if(null!=employee){
				EmployeeresReportService employeeReport=new EmployeeresReportService();
				employeeReport.buildReport(wwb, year, month);
			}
			if(null!=net){
				WangluoReportService netReport=new WangluoReportService();
				netReport.buildReport(wwb, year, month,request);
			}
			if(null!=groupjr){
				GroupjieruReportService groupjieruReport=new GroupjieruReportService();
				groupjieruReport.buildReport(wwb, year, month);
			}
			if(null!=netbusiness){
				NetresReportService netbusinessReport=new NetresReportService();
				netbusinessReport.buildReport(wwb, year, month);
			}
			if(null!=wuye){
				WuyeReportService wuyeReport=new WuyeReportService();
				wuyeReport.buildReport(wwb, year, month);
			}
			if(null!=office){
				OfficeReportService officeReport=new OfficeReportService();
				officeReport.buildReport(wwb, year, month);
			}
			if(null!=cheliang){
				CheliangReportService cheliangReport=new CheliangReportService();
				cheliangReport.buildReport(wwb, year, month);
			}
			if(null!=chanpin){
				YdproductresReportService chanpinReport=new YdproductresReportService();
				chanpinReport.buildReport(wwb, year, month);
			}
			if(null!=kpi){
				KpiReportService kpiReport=new KpiReportService();
				kpiReport.buildReport(wwb, year, month, request);
			}
			if(null!=mkehu){
				KehuReportService mkehuReport=new KehuReportService();
				mkehuReport.buildReport(wwb, year, month, request);
			}
			if(null!=shouru){
				ShouruReportService shouruReport=new ShouruReportService();
				shouruReport.buildReport(wwb, year, month, request);
			}
			if(null!=chengben){
				ChengbenReportService chengbenReport=new ChengbenReportService();
				chengbenReport.buildReport(wwb, year, month, request);
			}
			if(null!=groupproduct){
				GroupproductReportService groupproductReport=new GroupproductReportService();
				groupproductReport.buildReport(wwb, year, month, request);
			}
			wwb.write();
			wwb.close();
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
	public static void main(String []args){
		try {
			ReportService report=new ReportService();
			File file=new File("d:/report108.xls");
			FileOutputStream out=new FileOutputStream(file);
			report.buildReport(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"1","2008", "7",null,out);
			out.flush();
			out.close();
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}
}
